{% extends "layouts" ~ DIR ~ "default.twig" %}

{% block title %}{{ "Manage Webmentions" | translate("pingable") }}{% endblock %}

{% block content %}
<form class="filters" action="{{ url('manage_pingbacks') }}" method="post" accept-charset="UTF-8" role="search">
<fieldset role="presentation">
<label for="query">
{{ "Search&hellip;" | translate }}
<a href="{{ url('help/id/filtering_results') }}" rel="help" target="_blank" class="help emblem">
{{- icon_svg("help.svg", "Help" | translate) -}}
</a>
</label>
<input class="text filter_text" type="text" name="query" value="{{ GET.query | fix(true, true) }}" id="query">
<button type="submit">{{ "Search" | translate }}</button>
</fieldset>
</form>
<h2>{{ GET.query is not empty ? "Search Results" | translate : "Webmentions" | translate("pingable") }}</h2>
<table class="interactive">
<thead>
<tr class="head">
<th class="pingback_title title main">{{ "Title" | translate("pingable") }}</th>
<th class="pingback_post title">{{ "Post" | translate("pingable") }}</th>
<th class="pingback_date date">{{ "Added" | translate("pingable") }}</th>
{{ trigger.call("manage_pingbacks_column_header") }}
<th class="controls" colspan="2">{{ "Controls" | translate }}</th>
</tr>
</thead>
<tbody>
{% for pingback in pingbacks.paginated %}
<tr id="pingback_{{ pingback.id }}" class="pingback">
<td class="pingback_title title main">
<a href="{{ pingback.source | fix(true) }}">
{{ pingback.title | fix(false, true) | oneof("[Untitled]" | translate) | truncate(40) }}</a>
</td>
<td class="pingback_post title">
{% if not pingback.post.no_results %}
<a href="{{ pingback.post.url() }}#pingback_{{ pingback.id }}">
{{ pingback.post.title() | striptags | oneof("[Untitled]" | translate) | truncate(40) }}</a>
{% endif %}
</td>
<td class="pingback_date date">
{{ pingback.created_at | time }}
</td>
{{ trigger.call("manage_pingbacks_column", pingback) }}
<td class="controls">
{%- if pingback.editable() -%}
{{ pingback.edit_link(icon_svg("edit.svg", "Edit" | translate), null, null, "emblem") }}
{%- else -%}
{{ icon_svg("forbidden.svg", false, "emblem forbidden") }}
{%- endif -%}
</td>
<td class="controls">
{%- if pingback.deletable() -%}
{{ pingback.delete_link(icon_svg("delete.svg", "Delete" | translate), null, null, "emblem") }}
{%- else -%}
{{ icon_svg("forbidden.svg", false, "emblem forbidden") }}
{%- endif -%}
</td>
</tr>
{% else %}
<tr>
<td class="placeholder">
{{ icon_svg("failure.svg", false, "emblem") }}
{{ "No results" | translate }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% if pingbacks.paginated is not empty and pingbacks.pages > 1 %}
<div class="pagination">
<span class="pages">{{ "Page %d of %s" | translate | format(pingbacks.page, pingbacks.final_link(pingbacks.pages)) }}</span>
{{ pingbacks.prev_link }}
{{ pingbacks.next_link }}
</div>
{% endif %}
{% endblock %}
